#pragma once
#include <DSParaSet.h>
#include <DSMsgShower.h>
#include <string>

class CDSEnvItemInfo
{
//================ Define =================
public:
	static const int ENV_ITEM_NAME_BUF_SIZE = 512;
	static const int ENV_ITEM_GROUP_BUF_SIZE = 512;

	typedef enum
	{
		ENV_ITEM_TYPE_INIT = -1,
		ENV_ITEM_TYPE_PASS,
		ENV_ITEM_TYPE_BLOCK
	}enuDSEnvItemType;

	typedef struct
	{
		char szName[ENV_ITEM_NAME_BUF_SIZE];
		char szGroup[ENV_ITEM_GROUP_BUF_SIZE];
		char szPicFilePath[512];
		DSEnvItemType nEnvItemType;
		int nReserved;
	}CDSEnvItemData;

	protected:
		CString m_cstrName;
		CString m_cstrGroup;
		DSEnvItemType m_nEnvItemType;
		CDSEnvItemData m_cdsEnvItemData;

	public:
		CDSEnvItemInfo(void);
		~CDSEnvItemInfo(void);

	protected:
		void Initialize(void);

	public:
		inline void SetEnvItemName(const char* szName) { 
			m_cstrName.Format("%s", szName); 
			try
			{
				strcpy(this->m_cdsEnvItemData.szName, szName);
			}
			catch(std::bad_alloc ex)
			{
				CDSMsgShower::ShowMsgByErrorBox(NULL, "Error", MB_OK, "Fail to set environment item name(%s).\nThe buffer size is %d, but the length of inputted string is %d.",
																		szName, sizeof(m_cdsEnvItemData.szName), m_cstrName.GetLength());
			}
		};

		inline void SetGroup(const char* szGroup) { 
			m_cstrGroup.Format("%s", szGroup); 
			try
			{
				strcpy(this->m_cdsEnvItemData.szGroup, szGroup);
			}
			catch(std::bad_alloc ex)
			{
				CDSMsgShower::ShowMsgByErrorBox(NULL, "Error", MB_OK, "Fail to set environment item group(%s).\nThe buffer size is %d, but the length of inputted string is %d.",
																		szGroup, sizeof(m_cdsEnvItemData.szGroup), m_cstrGroup.GetLength());
			}
		};

		inline void SetPicFilePath(const char* szFilePath) 
		{
			try
			{
				strcpy(this->m_cdsEnvItemData.szPicFilePath, szFilePath);
			}
			catch(std::bad_alloc ex)
			{
				CDSMsgShower::ShowMsgByErrorBox(NULL, "Error", MB_OK, "Fail to set environment item picture(%s).\nThe buffer size is %d, but the length of inputted string is %d.",
																		szFilePath, sizeof(m_cdsEnvItemData.szPicFilePath), strlen(szFilePath));
			}
		};

		inline void SetType(DSEnvItemType nType) { 
			m_nEnvItemType = nType; 
			m_cdsEnvItemData.nEnvItemType = nType;
		};

		inline void SetEnvItemData(CDSEnvItemData cdsEnvItemData)
		{
			SetEnvItemName(cdsEnvItemData.szName);
			SetGroup(cdsEnvItemData.szGroup);
			SetType(cdsEnvItemData.nEnvItemType);
			strcpy(m_cdsEnvItemData.szPicFilePath, cdsEnvItemData.szPicFilePath);
		};

		inline const char* GetEnvItemName(void) { return m_cstrName; };
		inline const char* GetGroup(void) { return m_cstrGroup; };
		inline DSEnvItemType GetType(void) { return m_nEnvItemType; };
		inline const char* GetPicFilePath(void) { 
			return m_cdsEnvItemData.szPicFilePath; };

		inline CDSEnvItemData GetEnvItemData(void) { return m_cdsEnvItemData; };

};
